package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 风险记录字段值结果
 *
 * @author ytche
 * @date 2017年8月2日
 *
 */
@Entity
@Table(name = "TNB_RISK_FIELD_RESULT")
@JsonApiResource(type = "riskFieldResult")
public class RiskFieldResult extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private String remark;
	private String value;
	private RiskRecordResult recordResult;
	private RiskRecordField field;
	private RiskFieldEnum fieldEnum;

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "value")
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.SELECT)
	@JoinColumn(name = "record_result_id")
	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	public RiskRecordResult getRecordResult() {
		return recordResult;
	}

	public void setRecordResult(RiskRecordResult recordResult) {
		this.recordResult = recordResult;
	}

	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "field_id")
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public RiskRecordField getField() {
		return field;
	}

	public void setField(RiskRecordField field) {
		this.field = field;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "enum_id")
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public RiskFieldEnum getFieldEnum() {
		return fieldEnum;
	}

	public void setFieldEnum(RiskFieldEnum fieldEnum) {
		this.fieldEnum = fieldEnum;
	}
}
